package com.maisonliberte.util;

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.WebElement;
import org.openqa.selenium.htmlunit.HtmlUnitDriver;

import com.maisonliberte.conf.Config;

public class TranslateUtil {

	public static String translateJpnToKor(String q) throws Exception{
		String r = "";
		String url = Config.getInstance().translateUrl;
		try{

			WebDriver wd = new HtmlUnitDriver();
			wd.get(url);
				
			
			WebElement source = wd.findElement(By.id("source"));
			if(source != null){
				source.sendKeys(q);
				wd.findElement(By.id("gt-submit")).click();
			}
			
			WebElement result = wd.findElement(By.id("result_box"));
			if(result != null){
				r= result.getText();
			}
			
		}catch(Exception ex){
			System.out.println(ex.getMessage());
		}
		
		return r;
		
	}
	
}
